package com.bp.sms;

import java.util.Date;

import org.apache.log4j.Logger;

import com.bp.util.SmsConfig;
import com.bp.util.SystemUtil;
import com.bp.util.log.LogFactory;

public class SmsRequest extends Body {
    private static final Logger logger = LogFactory.getLogger(SmsRequest.class);
    private String transactionCode;
    private String organizationNum;
    private String tellerNum;
    private String terminalNum;
    private String transactionDate;
    private String transactionTime;
    private String phoneNum;
    private String busiContent;

    public SmsRequest(String phoneNum, String busiContent) {
        this.phoneNum = phoneNum;
        this.busiContent = busiContent;
    }

    public String createReq() {
        String result = "";
        try {
            this.transactionCode = SmsConfig.getValue("transactionCode");
            this.organizationNum = TransUtil.leftAlign(
                    SmsConfig.getValue("organizationNum"), 10);

            this.tellerNum = TransUtil.leftAlign(
                    SmsConfig.getValue("tellerNum"), 8);
            this.terminalNum = TransUtil.leftAlign(
                    SmsConfig.getValue("terminalNum"), 35);
            String tmpTime = SystemUtil.getFormatDate(new Date(),
                    "yyyyMMddHHmmss");
            this.transactionDate = tmpTime.substring(0, 8);
            this.transactionTime = tmpTime.substring(8);
            this.phoneNum = TransUtil.leftAlign(phoneNum, 15);
            this.busiContent = TransUtil.leftAlign(busiContent, 280);
            result = transactionCode + organizationNum + tellerNum
                    + terminalNum + transactionDate + transactionTime
                    + phoneNum + busiContent;
        } catch (Exception e) {
            logger.error("", e);
        }
        return result;
    }

    public String getTransactionCode() {
        return transactionCode;
    }

    public void setTransactionCode(String transactionCode) {
        this.transactionCode = transactionCode;
    }

    public String getOrganizationNum() {
        return organizationNum;
    }

    public void setOrganizationNum(String organizationNum) {
        this.organizationNum = organizationNum;
    }

    public String getTellerNum() {
        return tellerNum;
    }

    public void setTellerNum(String tellerNum) {
        this.tellerNum = tellerNum;
    }

    public String getTerminalNum() {
        return terminalNum;
    }

    public void setTerminalNum(String terminalNum) {
        this.terminalNum = terminalNum;
    }

    public String getTransactionDate() {
        return transactionDate;
    }

    public void setTransactionDate(String transactionDate) {
        this.transactionDate = transactionDate;
    }

    public String getTransactionTime() {
        return transactionTime;
    }

    public void setTransactionTime(String transactionTime) {
        this.transactionTime = transactionTime;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public String getBusiContent() {
        return busiContent;
    }

    public void setBusiContent(String busiContent) {
        this.busiContent = busiContent;
    }

}
